from Page.Page import Page
from selenium.webdriver.common.by import By

class Page2(Page):
    # 定位器
    # 搜索
    search_loc = (By.ID,'wd')
    # 搜索按钮
    search_btn_loc = (By.CLASS_NAME,'search-btn')
    # 选择商品
    choice_sp_loc = (By.XPATH,'/html/body/div[6]/div/div[2]/div[5]/ul/li[1]/div[2]/div[1]/a/img')
    # 加入购物车
    add_card_loc = (By.ID,'addToCartForDetail')

    # 封装方法
    # 搜索输入茅台
    def search(self):
        self.send_keys(self.search_loc,'茅台')
    # 点击搜索按钮
    def search_btn(self):
        self.click(self.search_btn_loc)
    # 选择茅台商品
    def choice_sp(self):
        self.click(self.choice_sp_loc)
    # 加入购物车
    def add_card(self):
        self.click(self.add_card_loc)